//
//  ByUISettingSelectView.m
//  laserdevice_ios
//
//  Created by pro on 16/11/24.
//  Copyright © 2016年 com.itboye. All rights reserved.
//

#import "ByUISettingSelectView.h"

@implementation ByUISettingSelectView

- (instancetype)initWithFrame:(CGRect)frame {
    
    if (self = [super initWithFrame:frame]) {
        
        [self setupUI];
    }
    
    return self;
}

- (void)setupUI {
 
    // 选中视图
    CGFloat side = 12;
    _selectView = [[UIImageView alloc] initWithFrame:CGRectMake(10, (self.height - side) / 2, side, side)];
    _selectView.image = [UIImage imageNamed:@"setting_selected"];
    _selectView.hidden = YES;
    [self addSubview:_selectView];
    
    // 内容label
    _contentLabel = [[UILabel alloc] initWithFrame:CGRectMake(_selectView.right + 5, 0, self.width - 10 - _selectView.right - 5, self.height)];
    _contentLabel.adjustsFontSizeToFitWidth = YES;
    _contentLabel.font = FONT(15);
    _contentLabel.textColor = TEXT_COLOR;
    _contentLabel.textAlignment = NSTextAlignmentLeft;
    [self addSubview:_contentLabel];
}


- (void)setSelected:(BOOL)selected {
    
    _selected = selected;
    
    // 根据是否选中来隐藏或显示选中视图
    _selectView.hidden = _selected ? NO : YES;
    
    // 根据是否选中来改变字体颜色
    _contentLabel.textColor = _selected ? CJ_THEME_COLOR : TEXT_COLOR;
}

@end
